#!/bin/sh

if [ -e config ]; then
	source config
else
	exit -1
fi

###### 如果文件丢失，就新建一个空文件

if [ -e memo.md ]; then 

	find . -mnewer memo.md | grep $tag | grep ".md" > tmp.list
else

	touch memo.md
fi

find . -mnewer memo.md | grep $tag | grep ".md"> tmp.list

if [ $? -ne 0 ]; then 
	echo $bookname "注解 OK"
	rm -f tmp.list
	exit 0
fi

echored $bookname

TMPFILE=`echo $0|awk -F/ '{print $NF}'``date|sed -e "s/ //g"`.tmp

rm -f memo.md
##touch memo.md

for files in ` ls  -l |sed -e '/^l/d'|awk '{print $NF}' |grep ^$tag`
do 

	getmemo $files  | sed -e "s/^\+ //g" >>memo.md

done

counter=`wc memo.md |awk '{print $1}'`

no $counter >no

sed -e "s/$/\. /" no >no.1

paste no.1 memo.md >$TMPFILE

awk '{print $0 "\n"}' $TMPFILE |sed -e "s/\t//g" > memo.md

rm -f no no.1 $TMPFILE tmp.list
